package com.lin.generator.data.domain;

import com.google.gson.Gson;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

/**
 * 列的属性
 *
 * @author 张林
 * @email 214641426@qq.com
 * @date 2016年12月20日 上午12:01:45
 */
public class ColumnEntity {
    //列名
    private String columnName;
//    是否是主键 手否是唯一 可包含的值有PRI，代表主键，UNI，代表唯一键，MUL，可重复。
    private String columnKey;
    //列名类型
    private String dataType;
    //列名备注
    private String comments;

    //属性名称(第一个字母大写)，如：user_name => UserName
    private String attrName;
    //属性名称(第一个字母小写)，如：user_name => userName
    private String attrname;
    //属性类型
    private String attrType;
    //auto_increment
    private String extra;


    private String isNullAble;
    // 是否可以为空IS_NULLABLE

    private ColumnInfo columnInfo;

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public String getDataType() {
        return dataType;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    public String getComments() {
        return comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }

    public String getAttrname() {
        return attrname;
    }

    public void setAttrname(String attrname) {
        this.attrname = attrname;
    }

    public String getAttrName() {
        return attrName;
    }

    public void setAttrName(String attrName) {
        this.attrName = attrName;
    }

    public String getAttrType() {
        return attrType;
    }

    public void setAttrType(String attrType) {
        this.attrType = attrType;
    }

    public String getExtra() {
        return extra;
    }

    public void setExtra(String extra) {
        this.extra = extra;
    }

    public String getIsNullAble() {
        return isNullAble;
    }

    public void setIsNullAble(String isNullAble) {
        this.isNullAble = isNullAble;
    }

    public String getColumnKey() {
        return columnKey;
    }

    public void setColumnKey(String columnKey) {
        this.columnKey = columnKey;
    }

    public ColumnInfo getColumnInfo() {
        return columnInfo;
    }

    public void setColumnInfo(ColumnInfo columnInfo) {
        this.columnInfo = columnInfo;
    }

    public void setColumnInfo(String columnInfoString,String tableName,String columnName) {
        Gson gson = new Gson();
        try {
            this.columnInfo = gson.fromJson(columnInfoString == null?"":columnInfoString,ColumnInfo.class);
        }catch (Exception e){
            e.printStackTrace();
            System.out.print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n ----\n----\n----\n ----\n"
                    + columnInfoString + "的字段" + columnName + "json 不正确"
                    + "---\n---\n---\n ---\n ----\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
        }
    }

    public class ColumnInfo{
        private boolean seach;
//        不能编辑
        private boolean noEdit;
        private boolean noNull;
        private ArrayList<Dic> dic;

        public boolean isSeach() {
            return seach;
        }

        public void setSeach(boolean seach) {
            this.seach = seach;
        }

        public boolean isNoEdit() {
            return noEdit;
        }

        public void setNoEdit(boolean noEdit) {
            this.noEdit = noEdit;
        }

        public ArrayList<Dic> getDic() {
            return dic;
        }

        public void setDic(ArrayList<Dic> dic) {
            this.dic = dic;
        }

        public boolean isNoNull() {
            return noNull;
        }

        public void setNoNull(boolean noNull) {
            this.noNull = noNull;
        }
    }
    //    字典

    public class Dic{
        private String v;
        private String n;

        public String getV() {
            return v;
        }

        public void setV(String v) {
            this.v = v;
        }

        public String getN() {
            return n;
        }

        public void setN(String n) {
            this.n = n;
        }

    }
}

